﻿using System.Collections.Generic;
using System.Web.Http;
using DefaultConnection;
using MementoWeb.Models;

namespace MementoWeb.Controllers
{
    public class ProjectController : ApiController
    {
        private readonly IDataRepository _dataRepository;

        public ProjectController( IDataRepository dataRepository )
        {
            _dataRepository = dataRepository;
        }

        public IEnumerable<Project> Get()
        {
            return _dataRepository.GetAllProjects();
        }

        public Project GetById( int id )
        {
            return _dataRepository.GetProjectById(id);
        }

        public void CreateNew( Project project )
        {
            _dataRepository.CreateNewProject(project);
        }

        public void Update( Project project )
        {
            _dataRepository.SaveProjectChanges(project);
        }

        public void Delete( int id )
        {
            _dataRepository.DeleteProject(id);
        }
    }
}
